@Aspect
@Order(1)
@Component
public class DataSourceAspect {
    @Pointcut(/* ... */)
    public void read() {
    }

    @Pointcut(/* ... */)
    public void write() {
    }

    @Before("write()")
    public void dispatchMasterDataSource() {
        DynamicDataSourceHolder.setMaster();
    }

    @Before("read()")
    public void dispatchSlaveDataSource() {
        DynamicDataSourceHolder.setSlave();
    }

    @After("read() || write()")
    public void clearDataSource() {
        DynamicDataSourceHolder.remove();
    }
}
